package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategyDoubleComment;
import cn.wolfcode.trip.base.mapper.StrategyContentMapper;
import cn.wolfcode.trip.base.mapper.StrategyDoubleCommentMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IStrategyDoubleCommentService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StrategyDoubleCommentServiceImpl implements IStrategyDoubleCommentService {
    @Autowired
    private StrategyDoubleCommentMapper strategyDoubleCommentMapper;
    @Autowired
    private StrategyContentMapper strategyContentMapper;

    public PageInfo list(QueryObject qo) {
        return null;
    }

    @Override
    public void saveOrUpdate(StrategyDoubleComment strategyDoubleComment) {
        if (strategyDoubleComment.getId()!=null){
            strategyDoubleCommentMapper.updateByPrimaryKey(strategyDoubleComment);
        }else {
            strategyDoubleComment.setUser(UserContext.getCurrentUser());
            strategyDoubleComment.setCreateTime(new Date());
            strategyDoubleComment.setCommendTime(new Date());
            strategyDoubleComment.setState(0);
            strategyDoubleCommentMapper.insert(strategyDoubleComment);
        }
    }


    public void updateState(StrategyDoubleComment strategyDoubleComment) {
    }

    @Override
    public List<StrategyDoubleComment> selectBystrategycommentId(Long strategycommentId) {
        List<StrategyDoubleComment> list = strategyDoubleCommentMapper.selectBystrategycommentId(strategycommentId);
        return list;
    }

    public PageInfo queryListByAuthorId(QueryObject qo) {
        return null;
    }

    @Override
    public int queryForCount(Long authorId) {
        return 0;
    }

    @Override
    public int selectCountNumBystrategycommentId(Long strategycommentId) {
        return strategyDoubleCommentMapper.selectCountNumBystrategycommentId(strategycommentId);
    }


}
